#include <stdio.h>

#define N 1000010
 
int a[N]; 
int p; 
int x0, y0; 

int get_gcd(int a, int b)
{
	int c; 
	while(1) {
		c = a%b; 
		if (c==0) {
			return b;
		}
		a = b; 
		b = c; 
	}
	return 1; 
}

int get_mcm(int a, int b, int gcd)
{
	return a*b/gcd; 
}

int main()
{
	int i, j; 
	int r = 0; 
	scanf("%d %d", &x0, &y0); 
	
	for (i=x0; i<=y0; i+=x0) {
		if ((y0%i)==0) {
			a[p++] = i; 
		}
	}
	for (i=0; i<p; i++) {
		for (j=0; j<p; j++) {
			if (i==j)
				continue; 
			if (get_gcd(a[i], a[j])!=x0) 
				continue; 
			if (get_mcm(a[i], a[j], x0)!=y0) 
				continue; 
			r ++; 
		}
	}
	printf("%d\n", r); 
	return 0; 
} 


